package com.nova.lfh.zxing;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;

import com.journeyapps.barcodescanner.CaptureManager;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;

public class RScannerActivity extends FragmentActivity {

	private DecoratedBarcodeView mBarcodeView;
	private CaptureManager capture;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate (savedInstanceState);
		setContentView (R.layout.activity_rscanner);
		mBarcodeView = (DecoratedBarcodeView) findViewById (R.id.zxing_barcode_scanner);
		capture = new CaptureManager (this, mBarcodeView);
		capture.initializeFromIntent (getIntent (), savedInstanceState);
		capture.decode ();
	}

	@Override
	protected void onResume() {
		super.onResume ();
		capture.onResume ();
	}

	@Override
	protected void onPause() {
		super.onPause ();
		capture.onPause ();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy ();
		capture.onDestroy ();
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState (outState);
		capture.onSaveInstanceState (outState);
	}

//	@Override
//	public boolean onSupportNavigateUp() {
//		onBackPressed ();
//		return true;
//	}


	@Override
	public boolean onNavigateUp() {
		onBackPressed ();
		return true;
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		return mBarcodeView.onKeyDown (keyCode, event) || super.onKeyDown (keyCode, event);
	}
}
